#!/usr/bin/env python
# -*- indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
# vi: set ts=4 sts=4 sw=4 set smarttab set expandtab
#http://www.careercup.com/question?id=12945663
#Facebook interview question
"""
Write a function f(n) which computes the number of scoring sequences that add up to score n.
"""

def calculate(num, scores, start_index):
    result = 0
    score = scores[start_index]
    if start_index == len(scores) - 1:
        return num % score == 0
    for i in range(0, num / score + 1):
        result += calculate(num - score * i, scores, start_index + 1)
    return result

scores = [3, 5, 7]
print calculate(21, scores, 0)
